<!DOCTYPE html>
<html lang="zh-cn">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Thinking</title>
    <link rel="stylesheet" href="/static/home/css/reset.css">
    <link rel="stylesheet" href="/static/home/css/swiper.min.css">
    <style>
        .main {
            font-family: 'Baskerville-Bold';
        }

        .menu {
            padding: 10px 100px 0 0;
            text-align: right;
        }

        .menu>a {
            padding-left: 10px;
            font-family: '黑体';
            color: #000;
            transition: all .3s;
        }

        .menu>a:hover {
            text-shadow: 1px 1px 2px rgba(0, 0, 0, .4);
        }

        .thinking {
            font-weight: bold;
        }

        .main>.img-box {
            padding: 30px;
            margin: auto;
        }

        .three,
        .two {
            display: flex;
            justify-content: space-between;
            align-items: flex-end;
            padding-bottom: 20px;
        }

        .three img,
        .two img {
            width: 100%;
        }

        .three>.img-wapper {
            /* width: 253.3px; */
            width: 33.33%;
            padding-right: 30px;
            box-sizing: border-box;
        }

        .three>.img-wapper:last-child {
            padding-right: 0;
        }

        .two {
            justify-content: flex-end;
        }

        .two>.img-wapper {
            width: 50%;
            padding-right: 30px;
            box-sizing: border-box;
        }

        .two>.img-wapper:last-child {
            padding-right: 0;
        }

        .main>.img-box img {
            cursor: pointer;
            transition: all .3s;
        }

        .main>.img-box img:hover {
            box-shadow: 0 0 20px 0 rgba(0, 0, 0, 1);
        }

        .pop {
            overflow-y: auto;
            display: none;
            position: fixed;
            left: 0;
            top: 0;
            right: 0;
            bottom: 0;
            color: #fff;
            background-color: #4A4A4A;
        }

        .close {
            z-index: 9999;
            position: absolute;
            right: 20px;
            top: 20px;
            height: 50px;
            width: 50px;
            background-color: #fff;
            border-radius: 50%;
            cursor: pointer;
            box-shadow: 0 0 2px 0 #000;
        }

        .close::after {
            content: 'X';
            position: absolute;
            left: 50%;
            top: 50%;
            transform: translate(-50%, -50%);
            font-size: 20px;
            color: #000;
        }

        .pop>.img-box {
            position: relative;
            height: 360px;
            width: 100%;
        }

        .swiper-container {
            width: 100%;
            height: 100%;
        }

        .swiper-slide {
            width: 240px;
            text-align: center;
            font-size: 18px;
            background-size: contain;
            background-position: center bottom;
            background-repeat: no-repeat;

            /* Center slide text vertically */
            display: -webkit-box;
            display: -ms-flexbox;
            display: -webkit-flex;
            display: flex;
            -webkit-box-pack: center;
            -ms-flex-pack: center;
            -webkit-justify-content: center;
            justify-content: center;
            -webkit-box-align: center;
            -ms-flex-align: center;
            -webkit-align-items: center;
            align-items: flex-end;
        }

        .swiper-slide>img {
            width: 100%;
        }

        .swiper-slide:first-child {
            margin-left: 200px;
            box-sizing: border-box;
        }

        .pop>.img-box .pager {
            position: absolute;
            right: 20px;
            bottom: -80px;
        }

        .pop>.img-box .pager span {
            display: block;
            font-size: 16px;
            line-height: 30px;
            height: 30px;
            cursor: pointer;
        }

        .pop>.img-box .pager span:hover {
            color: #ddd;
        }

        .pop .intro {
            padding: 20px 0 0 240px;
            width: 500px;
            font-size: 14px;
            word-break: break-all;
            word-wrap: break-word;
        }

        .pop .info {
            padding: 40px 0 20px 200px;
            width: 500px;
            font-size: 12px;
        }

        .swiper-slide>img {
            width: 100%;
            margin-right: 30px;
        }
    </style>
    <style>
        @media screen and (max-width: 420px) {
            .main>.img-box {
                padding: 30px;
            }

            .pop .intro,
            .pop .info {
                padding: 20px;
                box-sizing: border-box;
                width: auto;
            }

            .pop>.img-box .pager {
                bottom: 0;
                z-index: 9999;
            }
        }
    </style>
    <script src="/static/home/js/jquery.min.js"></script>
</head>

<body>
    <div class="main">
        <div class="menu">
            <a class="thinking" href="/home/index/thinking">Thinking</a>
            <a class="keynote-book" href="/home/index/keynote">KeynoteBook</a>
        </div>
        <div class="img-box">
            {volist name='data' id='value'}
            <div class="three">
                {foreach name='value' item='val' key='k'}
                <div class="img-wapper"><img src="{$val.image}" alt="{$val.name}" data-id="{$val.id}"></div>
                {if $k eq 2}
            </div>
            <div class="two">
                {/if}
                {/foreach}
            </div>
            {/volist}
            {volist name='data' id='value'}
            <div class="three">
                {foreach name='value' item='val' key='k'}
                <div class="img-wapper"><img src="{$val.image}" alt="{$val.name}" data-id="{$val.id}"></div>
                {if $k eq 2}
            </div>
            <div class="two">
                {/if}
                {/foreach}
            </div>
            {/volist}
            <script>
                var data = '<?php echo $file;?>'
            </script>
            {$result->render()|raw}
        </div>
    </div>
    <div class="pop">
        <div class="img-box">
            <div class="swiper-container">
                <div class="swiper-wrapper js-img-box">
                    <!--{volist name='result.data' id='value'}
                <div class="swiper-slide"><img src="{$value.image}" alt="img1"></div>
                {/volist}
                <div class="swiper-slide" style="width:200px"></div>-->
                </div>
            </div>
            <div class="pager">
                <span class="prev js-prev">PREV</span>
                <span class="next js-next">NEXT</span>
            </div>
        </div>
        <div class="intro js-intro">

        </div>
        <div class="info js-info">

        </div>
        <div class="close"></div>
    </div>
</body>
<script>
    var swiper;
    var _data = JSON.parse(window.data);
    // 当前查看的图片key
    var currKey;
    var keys = Object.keys(_data);
    //console.log(keys)
    $('img').click(function () {
        // 存储当前key
        currKey = $(this).attr('data-id');

        getCurrObj();
    });

    $('.close').click(function () {
        location.href = '/';
        $('.pop').fadeOut();
        $('html,body').css('overflow-y', 'auto');
    });

    $('.js-prev').click(function () {
        // 上一个组：currKey在keys数组中的索引 - 1
        let index = keys.indexOf(currKey) - 1;
        if (index < 0) {
            return;
        }

        // 获取索对应的key
        currKey = keys[index];
        getCurrObj();
    });

    $('.js-next').click(function () {
        let index = keys.indexOf(currKey) + 1;
        if (index > keys.length - 1) {
            return;
        }

        // 获取索对应的key
        currKey = keys[index];
        getCurrObj();
    });

    function getCurrObj() {
        swiper && swiper.destroy && swiper.destroy();

        var obj = _data[currKey];
        var strHtml = '';

        obj.imglist.forEach(function (item) {
            strHtml += '<div class="swiper-slide" style="background-image:url(' + item + ')"></div>'
        });

        strHtml += '<div class="swiper-slide" style="width:200px"></div>';
        $('.js-img-box').html(strHtml);

        $('.js-intro').html(obj.description);

        $('.pop').fadeIn();
        $('html,body').css('overflow-y', 'hidden');

        swiper = new Swiper('.swiper-container', {
            slidesPerView: 'auto',
            spaceBetween: 30
        });
    }
</script>
<script src="/static/home/js/swiper.min.js"></script>

</html>